﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NeuralNetwork.Normalization
{
    abstract public class NormalizeFunction
    {
        abstract public void Normalize(List<double> input);
    }

    public class Multiplicative : NormalizeFunction
    {        
        override public void Normalize(List<double> input)
        {
            double factor = 0;
            foreach(double d in input) factor += (d * d);
            factor = Math.Sqrt(factor);

            for (int i = 0; i < input.Count; i++)
            {
                input[i] = input[i] / factor; 
            }
        }
    }

    public class ZAxis : NormalizeFunction
    {
        override public void Normalize(List<double> input)
        {
            double f = 1 / Math.Sqrt(input.Count);

            double l = 0;
            foreach (double d in input) l += (d * d);

            double factor = f * Math.Sqrt(input.Count - l);

            for (int i = 0; i < input.Count; i++)
            {
                input[i] = input[i] * factor;
            }
        }
    }
}
